package com.wonder.constant;

import com.vtuzx.core.constant.IVtuzxConst;
import com.vtuzx.core.utils.VtuzxUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 秒和中心常量
 */
public interface IXqcConst extends IVtuzxConst {
    /** 接口相关错误消息 */
    String Msg_E_XQC_box_err = "E_XQC_0001";
    String Msg_E_XQC_sign_err = "E_XQC_0002";
    String Msg_E_XQC_if_timeout = "E_XQC_0003";
    /** 在库相关错误消息 */
    String Msg_E_XQC_box_not_exist = "E_XQC_1001";
    String Msg_E_XQC_stock_bill_failure = "E_XQC_1002";
    String Msg_E_XQC_stock_event_failure = "E_XQC_1003";
    String Msg_E_XQC_stock_pur_col_in_stock = "E_XQC_1004";
    String Msg_E_XQC_stock_out_bill_failure = "E_XQC_1005";
    String Msg_E_XQC_stock_out_event_failure = "E_XQC_1006";
    String Msg_E_XQC_stock_out_exist = "E_XQC_1007";
    String Msg_E_XQC_in_stock = "E_XQC_1008";
    String Msg_E_XQC_box_not_audit = "E_XQC_1009";
    String Msg_E_XQC_box_not_in_inventory = "E_XQC_1010";

    /**
     * 创建事务Key
     *
     * @return 事务Key
     */
    static String getTransactionKey() {
        return System.currentTimeMillis() + VtuzxUtil.random(6);
    }

    /**
     * 创建单号
     *
     * @return 单号
     */
    static String createBillNo(BillType billType) {
        String pre = billType.toString();
        String timestamp = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date());
        return pre + timestamp;
    }
    /**
     * 创建单号
     *
     * @return 单号
     */
    static String createBillNo2(BillType billType) {
        String pre = billType.toString();
        long timestamp = System.currentTimeMillis();
        int random = VtuzxUtil.randomNumeric(10, 99);
        return pre + timestamp + random;
    }
}
